package com.hdd.art.biz.show.controller;


import com.hdd.art.biz.show.dto.ShowroomRuleDto;
import com.hdd.art.biz.show.entity.ShowroomRule;
import com.hdd.art.biz.show.service.ShowroomRuleService;
import com.hdd.art.dto.AppResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author fang
 * @since 2021-07-10
 */
@RestController
@RequestMapping("/show/showroom-rule")
@Api(value = "美术馆-展区规则",tags = {"美术馆-展区规则"})
public class ShowroomRuleController {

    @Autowired
    private ShowroomRuleService showroomRuleService;

    @PostMapping("/info")
    @ApiOperation(value = "获取规则" ,notes = "")
    public AppResponse info(@Valid @RequestBody ShowroomRuleDto ruleDto ){
        AppResponse response = new AppResponse();
        response.setItem(showroomRuleService.find(ruleDto.getRoomId()));
        return response;
    }


    @PostMapping("/update")
    @ApiOperation(value = "修改规则" ,notes = "")
    public AppResponse update(@Valid @RequestBody ShowroomRuleDto ruleDto ){
        AppResponse response = new AppResponse();
        ShowroomRule showroomRule = new  ShowroomRule();
        BeanUtils.copyProperties(ruleDto,showroomRule);
        showroomRuleService.update(showroomRule);
        return response;
    }



}

